package com.YK.retryer.strategy.annotationwrapper.resultwrapper.impl;

import com.YK.retryer.strategy.annotationwrapper.resultwrapper.AbstractResultListPredicateWrapper;
import com.YK.retryer.util.predicate.NormalResultPredicateUtil;
import com.YK.retryer.util.predicate.ThrowResultPredicateUtil;

/**
 * @author yuank
 * @version 1.0.0
 * @date 2025/2/27 16:31:38
 *
 * 对返回结果转换为json后进行等值匹配的策略器
 * 支持用Json结构来表达返回结果: {
 *      String[] result = {"123", "true"};
 *      Class[] resultClass = {Integer.class, Boolean.class};
 *    }
 */

/*com.YK.autoconfig.YKRetryAutoConfig.getObjectResultPredicate 已声明原型bean*/
public class ObjectResultListPredicate extends AbstractResultListPredicateWrapper {

    @Override
    public boolean test(Object o) {
        if (o instanceof Throwable) {
            return ThrowResultPredicateUtil.retry(getObjectList(), o);

        }
        return NormalResultPredicateUtil.retry(getObjectList(), o);
    }

}